<template>
  <div style="width: 66%;display: flex">
    <div style="flex:5"></div>
    <div style="flex:5">
      <el-form label-position="top" label-width="80px" :model="formData" class="login-form">
        <h2>管理员登录</h2>
        <el-form-item label="管理员名">
          <el-input v-model="formData.name"></el-input>
        </el-form-item>
        <el-form-item label="密码">
          <el-input v-model="formData.password" type="password"></el-input>
        </el-form-item>
        <el-button @click="login" class="login-button" type="primary">登录</el-button>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {


  data() {
    return {
      formData: {
        name: '',
        password: ''
      }
    }
  },
  methods:
      {
        async login() {
          let result = await this.$axios.post('/Alog', this.formData);

          if (result.data.status == 200) {

            console.log(result.data.data)
            localStorage.setItem('AId', result.data.data.id)
            console.log("AId: " + result.data.data.id)
            console.log(localStorage.getItem('AId').toString())
            this.$router.push('/Ahome')

          } else {
            this.$message(
                {
                  type: 'error',
                  message: '用户名或密码错误'
                }
            )
            console.log(this.formData)

          }

        }

      }

}
</script>

<style scoped>

</style>